/*
 * mathutils.cpp
 *
 *  Created on: Jan 25, 2009
 *      Author: Jesse Lovitt
 */

#include "mathutils.h"

float rad2deg(float rad)
{
	return (rad*180/PI);
}
float deg2rad(float deg)
{
	return (deg*PI/180);
}
float normalizerad(float rad)
{
	while(rad>PI)
	{
		rad -= 2*PI; 
	}
	while (rad<-PI)
	{
		rad += 2*PI;
	}
	return rad;
}
float normalizedeg(float deg)
{
	while (deg>180)
	{
		deg -=360;
	}
	while (deg < 180)
	{
		deg += 360;
	}
	return deg;
}

float Differencef(float a, float b)
{
	if (a > b)
	{
		return a - b;
	}
	
	if (b > a)
	{
		return b - a;
	}

	if (a == b)
	{
		return 0.0f;
	}
	else
	{
		return 0.0f;
	}
}
